package nettyTest.util;

import io.netty.util.HashedWheelTimer;
import io.netty.util.Timeout;
import io.netty.util.TimerTask;

import java.io.IOException;
import java.util.Date;
import java.util.concurrent.TimeUnit;

public class HashedWheelTimerTest {

    public static void main(String[] args) {
        HashedWheelTimer timer = new HashedWheelTimer();

        System.out.println(new Date());

        MyTask task1 = new MyTask();
        MyTask task2 = new MyTask();
        MyTask task3 = new MyTask();

        for (int i = 0; i < 1000000; i++) {
            timer.newTimeout(new MyTask(), 3, TimeUnit.SECONDS);
        }
        try {
            System.in.read();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

class MyTask implements TimerTask {

    @Override
    public void run(Timeout timeout) throws Exception {

        Thread.sleep(1);
        System.out.println("test " + timeout + " == " +  new Date());
    }
}
